﻿#region Regions

using System;
using System.IO;
using System.Text;

using FMWare.Core.Objects;

#endregion

namespace FMWare.Core.Base
{
	internal class BinaryWriter : System.IO.BinaryWriter
	{
		#region Constructors

		public BinaryWriter(Stream output)
			: base(output) {}

		public BinaryWriter(Stream output, Encoding encoding)
			: base(output, encoding) {}

		#endregion

		#region Public Methods

		public override void Write(string value)
		{
			Write(value.Length);
			if (value.Length > 0)
			{
				Write(value.ToCharArray());
				Write(new byte());
				Write(new byte());
			}
		}

		public void Write(Kit kit)
		{
			Write(kit.ForeColor);
			Write(kit.BackColor);
			Write(kit.Outline);
			Write((Byte) kit.Style);
		}

		public void Write(DateTime dateTime)
		{
			short days = (short) (dateTime.DayOfYear - 1);
			Write(days);
			Write((Int16) dateTime.Year);
		}

		#endregion
	}
}